import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    tags: [
      { id: 0, path: "/index/about", title: "关于" },
      { id: 1, path: "" },//商品信息
      { id: 2, path: "" }, //添加商品
      { id: 3, path: "" }
    ],
    isCollapse: false
  },
  mutations: {
    addtags(state, payload) {
      for (const item of state.tags) {
        if (item.path == "") {
          if (item.id == payload.id) {
            // console.log("添加成功")
            item.path = payload.key == undefined ? payload.path : payload.key
            item.title = payload.title
          }

        }
      }
    },
    deletetags(state, payload) {
      for (const item of state.tags) {
        if (item.id == payload) {
          item.path = ""
          break;
        }
      }
    },
    ChangeCollapse(state, payload) {
      // console.log("触发")
      state.isCollapse = payload
    }
  },
  actions: {
  },
  modules: {
  }
})
